home *** CD-ROM | disk | FTP | other *** search
- // =================================================================================
- // NatFTP.h ©1998 Sustainable Softworks. All rights reserved.
- // =================================================================================
- // Network Address Translation for Embedded FTP Control channel
- // This module translates the data portion of IP datagrams
- // (technically a layering violation)
- //
- // Since we must operate in the STREAMS context, this module is written
- // in traditional C (not C++).
-
- #ifndef _H_NatFTP
- #define _H_NatFTP
- #pragma once
-
- #include "NatTable.h"
- #define nilp(type) ((type*)0)
-
- // ---------------------------------------------------------------------------
- // • Convert2ApparentFtp
- // ---------------------------------------------------------------------------
- // Convert outgoing datagrams to appear as if they originate from
- // the apparent endpoint. Return false if not a valid datagram or
- // no translation entry could be found or created.
- //
- // Handle embedded ftp control data
- // We assume there can only be one PORT command per segment!
- Boolean
- Convert2ApparentFtp(translationEntry_t table[],
- UInt8* datagram,
- mblk_t* mp,
- translationEntry_t* inLookupEntry,
- ip_header_t* ipHeader,
- tcp_header_t* tcpHeader);
-
- // ---------------------------------------------------------------------------
- // • Convert2ActualFtp
- // ---------------------------------------------------------------------------
- // Convert incomming datagram addressed to an apparent endpoint to
- // be forwarded to the corresponding actual endpoint.
- //
- // Handle embedded ftp control data
- // We assume there can only be one PORT command per segment!
- Boolean
- Convert2ActualFtp(translationEntry_t table[],
- UInt8* datagram,
- mblk_t* mp,
- translationEntry_t* inLookupEntry,
- ip_header_t* ipHeader,
- tcp_header_t* tcpHeader);
-
-
- // ---------------------------------------------------------------------------
- // • DecodeFTPPort
- // ---------------------------------------------------------------------------
- // Convert FTP "PORT n1,n2,n3,n4,n5,n6" command to address and protocol port
- // Return length of PORT command, or Zero if command error detected
- UInt8
- DecodeFTPPort(UInt8* inStr, UInt16 inSize, UInt32* outAddr, UInt16* outPort);
-
- // ---------------------------------------------------------------------------
- // • EncodeFTPPort
- // ---------------------------------------------------------------------------
- // Convert address and protocol port to FTP "PORT n1,n2,n3,n4,n5,n6\r\n" command
- // Output as null terminated string.
- UInt8
- EncodeFTPPort(UInt32 inAddr, UInt16 inPort, char* outStr);
-
- #define kFtpControlPort 21
- #define kFtpDataPort 20
-
- #endif